package commands;

import nanoxml.XMLElement;
import utils.ITransmittable;
import utils.Utils;

/**
 * This command is used to transfer to players and users
 * the currant state of a player's army.
 */
public class CommandArmy implements ITransmittable {

	private final static String ATTR_ARMY = "Army";
	private final static String ATTR_USERNAME = "Username";
	
    private String[] army = null;
    private String username = null;

    public CommandArmy (String [] army , String username) {
    	this.army = army;
    	this.username = username;
    }
 
    public CommandArmy (XMLElement message) {
    	this.army = Utils.convertToStringArray((String)message.getAttribute(ATTR_ARMY));
    	this.username = (String) message.getAttribute(ATTR_USERNAME);
    }

	public XMLElement toXML () {
		XMLElement element = new XMLElement();
		element.setName(Commands.ARMY);
		element.setAttribute(ATTR_ARMY, Utils.valueOf(this.army));
		element.setAttribute(ATTR_USERNAME, this.username);
		return element;
	}
	public String[] getArmy() {
		return army;
	}
	public String getUsername() {
		return username;
	}
}
